package lzyc.pointsManagement.web.controller.business;

import lzyc.pointsManagement.business.activity.dto.ActivityApplyDto;
import lzyc.pointsManagement.business.activity.dto.ActivityInfoDto;
import lzyc.pointsManagement.business.approval.service.ApprovalInfoService;
import lzyc.pointsManagement.business.service.ActivityApplyService;
import lzyc.pointsManagement.business.service.ActivityInfoService;
import lzyc.pointsManagement.common.core.page.PageDomain;
import lzyc.pointsManagement.common.response.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/event")
public class ActivityInfoController {
    @Autowired
    ActivityInfoService activityInfoService;

    @Autowired
    ActivityApplyService activityApplyService;

    @Autowired
    private ApprovalInfoService approvalInfoService;

    @PostMapping("/add")
    @ResponseBody
    public ResponseMessage add(@RequestBody ActivityInfoDto activityInfo) {
        return activityInfoService.addActivityInfo(activityInfo);
    }

    /**
     * 获取所有活动信息的控制器方法。
     *
     * 该方法不需要接收任何参数，通过调用 {@link ActivityInfoService#getAllActivityInfo(PageDomain)} 方法，
     * 获取所有活动的信息列表，并将这个列表作为响应体返回给客户端。
     *
     * @return 返回一个包含所有活动信息的列表。列表的元素类型是 {@link ActivityInfoDto}。
     */
    @PostMapping("/list")
    @ResponseBody
    public ResponseMessage getAllActivityInfo(@RequestBody PageDomain pageInfo) {
        return activityInfoService.getAllActivityInfo(pageInfo);
    }

    /**
     * 根据活动ID获取活动信息。
     *
     * @param id 活动的唯一标识符。
     * @return 返回一个包含活动信息的ResponseMessage对象。
     */
    @PostMapping("/detail")
    @ResponseBody
    public ResponseMessage getActivityInfoById(@RequestParam String id) {
        // 通过活动ID从服务层获取活动信息并返回
        return activityInfoService.getActivityInfoById(id);
    }

    @PostMapping("/join")
    @ResponseBody
    public ResponseMessage getJoinActivityUser(@RequestParam String activityId) {
        // 通过活动ID从服务层获取活动信息并返回
        return activityApplyService.getJoinActivityUser(activityId);
    }

    @PostMapping("/unjoin")
    @ResponseBody
    public ResponseMessage getUnJoinActivityUser(@RequestParam String activityId) {
        // 通过活动ID从服务层获取活动信息并返回
        return activityApplyService.getUnJoinActivityUser(activityId);
    }

    @PostMapping("/update")
    @ResponseBody
    public ResponseMessage updateActivityInfo(@RequestBody ActivityInfoDto activityInfoDto) {
        return activityInfoService.updateActivityInfo(activityInfoDto);
    }

    @PostMapping("/delete")
    @ResponseBody
    public ResponseMessage deleteActivityInfo(@RequestParam String id) {
        return activityInfoService.deleteActivityInfo(id);
    }

    @PostMapping("/apply/list/temp")
    @ResponseBody
    public ResponseMessage getActivityApplyList(@RequestBody PageDomain pageInfo) {
        return activityApplyService.getActivityApplyList(pageInfo);
    }

    @PostMapping("/apply/list")
    @ResponseBody
    public ResponseMessage getActivityApplyListByActivityId(@RequestParam String activityId, @RequestBody PageDomain pageInfo) {
        return activityApplyService.getActivityApplyByActivityId(activityId, pageInfo);
    }

    @PostMapping("/apply/detail")
    @ResponseBody
    public ResponseMessage getActivityApplyById(@RequestParam String id) {
        return activityApplyService.getActivityApplyById(id);
    }

    @PostMapping("/apply/add")
    @ResponseBody
    public ResponseMessage activityApplyAdd(@RequestBody ActivityApplyDto dto) {
        return activityApplyService.addActivityApply(dto);
    }

    @PostMapping("/apply/review")
    @ResponseBody
    public ResponseMessage activityApplyReview(@RequestParam String approvalId, @RequestParam String status) {
        return approvalInfoService.applyReview(approvalId, status);
    }

}
